package com.fqgj.report.statistics.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.common.utils.CollectionUtils;
import com.fqgj.report.statistics.dao.BiInvokingStatDao;
import com.fqgj.report.statistics.entity.BiInvokingStatEntity;
import com.fqgj.report.statistics.entity.BiInvokingStatisticEntity;
import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: zzzz76
 * Date: 2017-12-14
 * Time: 13:23:44.202
 */

@Repository
public class BiInvokingStatDaoImpl extends AbstractBaseMapper<BiInvokingStatEntity> implements BiInvokingStatDao {
    @Autowired
    @Qualifier("sqlSessionFactory2")
    private SqlSessionFactory sqlSessionFactory;

    @Override
    public List<BiInvokingStatisticEntity> selectTripleCallStatistics(String startDate, String endDate,
                                                                      Integer productType, List<Integer> tripleTypeList) {
        Map<String, Object> param = new HashMap<>();
        param.put("startDate", startDate);
        param.put("endDate", endDate);
        param.put("productType", productType);
        if (CollectionUtils.isEmpty(tripleTypeList)) {
            param.put("tripleTypeList", null);
        } else {
            param.put("tripleTypeList", tripleTypeList);
        }
        SqlSession sqlSession = new SqlSessionTemplate(sqlSessionFactory);
        return sqlSession.selectList(getStatement(".selectTripleCallStatistics"), param);
    }
}